// 大仓库
import { combineReducers } from 'redux'
import { configureStore } from '@reduxjs/toolkit'
import thunk from 'redux-thunk'
import { ThunkMiddleware } from 'redux-thunk'
import userReducer, { UserActions } from './modules/user'
import mainReducer, { MainActions } from './modules/main'

// 总reducer
const reducer = combineReducers({
  user: userReducer,
  main: mainReducer,
})

const store = configureStore({
  reducer,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware().concat(thunk as unknown as ThunkMiddleware),
})

export default store

// 统一导入各自仓库中的ActionsCreate再统一导出。
export { UserActions, MainActions }
